package com.chinaunicom.create.singleton.lazy;

/**
 * @author liry
 * @version 1.0
 * @date Created on 2022/7/14 11:09
 * Description: 懒汉模式（静态代码块） === (静态常量)
 */
public class LSingleton02 {
    
    // 静态常量：创建对象
    private static LSingleton02 LSingleton02;
    
    
    static {
        System.out.println("静态代码块.....");
        LSingleton02 = new LSingleton02();
    }
    
    private LSingleton02(){}
    
    public static LSingleton02 getInstance(){
        return LSingleton02;
    }


    public static void main(String[] args) {
        LSingleton02 instance1 = LSingleton02.getInstance();

        LSingleton02 instance2 = LSingleton02.getInstance();

        System.out.println(instance1.equals(instance2));
    }
}
